import QtQuick 2.15
import QtQuick.Controls 2.15
Item {
    id: root
    width: 80
    height: 120
    property int no:-1
    property int addr:240
    property int addrIndex:-1
    function getAddr(){
        var lst=[];
        for(let i=1;i<256;i++){
            lst.push(i)
        }
        return lst
    }
    function getText(){
        switch(no){
            case 0:
                return mymodbus.voltage0;
            case 1:
                return mymodbus.voltage1;
            case 2:
                return mymodbus.voltage2;
            case 3:
                return mymodbus.voltage3;
            case 4:
                return mymodbus.voltage4;
            case 5:
                return mymodbus.voltage5;
            case 6:
                return mymodbus.voltage6;
            case 7:
                return mymodbus.voltage7;
        }
    }
    Component.onCompleted: {
        weigherValue.text = getText()
    }
    Rectangle{
        id:rec
        anchors.fill:parent
        color:"#7142ED"
        Text {
            id: weigherName
            text:qsTr("轴")+(no+1).toString()
            font.pixelSize: 20
            font.weight: Font.Medium
            color: "white"
            height: 30
            anchors.topMargin: 0
            anchors.top: parent.top

        }
        Text {
            horizontalAlignment: Text.AlignHCenter
            id: weigherValue
            x: 0
            width: 80
            text: ""
            font.pixelSize: 20
            font.weight: Font.Medium
            color: "white"
            height: 30
            anchors.topMargin: 48
            anchors.top: parent.top

        }
    }
    Timer{
        interval: mymodbus.collectTime
        running: true
        repeat: true
        onTriggered: {
            weigherValue.text = getText()
        }

    }
}

